package com.Earth01;
/*
* 237. 删除链表中的节点
* */
public class Earth240713 {
    public static void main(String[] args) {
        //4 5 1 9
        ListNode ln1 = new ListNode(4);
        ListNode ln2 = new ListNode(5);
        ListNode ln3 = new ListNode(1);
        ListNode ln4 = new ListNode(9);
        ln1.next = ln2;
        ln2.next = ln3;
        ln3.next = ln4;
        ln4.next = null;
        ListNode head = ln1;
        deleteNode(ln2);
        while(true){
            if(head == null){
                break;
            }
            System.out.println(head.val);
            head = head.next;
        }

    }
    public static void deleteNode(ListNode node) {
        node.val = node.next.val;
        node.next = node.next.next;
    }

}
class ListNode{
    int val;
    ListNode next;
    ListNode(){}
    ListNode(int x) { val = x; }
}
